package com.burstly.lib.component.networkcomponent.inmobi;

import com.burstly.lib.component.networkcomponent.AbstractNetworkConfigurator;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;
import com.inmobi.androidsdk.IMAdRequest;
import com.inmobi.androidsdk.IMAdRequest.EducationType;
import com.inmobi.androidsdk.IMAdRequest.EthnicityType;
import com.inmobi.androidsdk.IMAdRequest.GenderType;
import com.inmobi.androidsdk.IMAdRequest.IMIDType;
import com.inmobi.commons.IMCommonUtil;
import com.inmobi.commons.IMCommonUtil.LOG_LEVEL;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

class InmobiConfigurator extends AbstractNetworkConfigurator<IMAdRequest>
{
  public static final String IS_INTERSTITIAL = "isInterstitial";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  public static final String LOG_LEVEL = "logLevel";
  public static final String LOG_LEVEL_VERBOSE = "verbose";
  private static final String TAG = InmobiConfigurator.class.getSimpleName();
  public static final String TEST_MODE = "testMode";
  private int mAdUnit;
  private int mAge;
  private String mAppId;
  private String mAreaCode;
  private String mCity;
  private String mCountry;
  private Date mDateOfBirth;
  private int mDeviceIdMask;
  private IMAdRequest.EducationType mEducationType;
  private IMAdRequest.EthnicityType mEthnicityType;
  private IMAdRequest.GenderType mGenderType;
  private IMAdRequest.IMIDType mIdType;
  private String mIdTypeValue;
  private int mIncome;
  private String mInterests;
  private boolean mIsInterstitial;
  private boolean mIsLocationAllowed;
  private boolean mIsTestMode;
  private String mKeywords;
  private String mLogLevel;
  private String mPostalCode;
  private String mSearchString;
  private String mState;

  private static void enableProperLogLevel(String paramString)
  {
    if ("verbose".equalsIgnoreCase(paramString))
    {
      IMCommonUtil.setLogLevel(IMCommonUtil.LOG_LEVEL.DEBUG);
      return;
    }
    IMCommonUtil.setLogLevel(IMCommonUtil.LOG_LEVEL.NONE);
  }

  private void extractCityStateCountryLocation(Map<String, ?> paramMap)
  {
    String str1 = (String)paramMap.get("city");
    String str2 = (String)paramMap.get("state");
    String str3 = (String)paramMap.get("country");
    if ((str1 != null) && (str1.length() > 0) && (str2 != null) && (str2.length() > 0) && (str3 != null) && (str3.length() > 0))
    {
      this.mCity = str1;
      this.mState = str2;
      this.mCountry = str3;
    }
  }

  private void extractIdType(Map<String, ?> paramMap)
  {
    String str1 = (String)paramMap.get("idType");
    String str2 = (String)paramMap.get("idTypeValue");
    if ((str1 != null) && (str2 != null));
    try
    {
      this.mIdType = IMAdRequest.IMIDType.valueOf(str1.toUpperCase());
      this.mIdTypeValue = str2;
      return;
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
    }
  }

  private int getAdUnitCode(String paramString)
  {
    if ("120x600".equalsIgnoreCase(paramString))
      return 13;
    if ("300x250".equalsIgnoreCase(paramString))
      return 10;
    if ("468x60".equalsIgnoreCase(paramString))
      return 12;
    if ("728x90".equalsIgnoreCase(paramString))
      return 11;
    if ("320x48".equalsIgnoreCase(paramString))
      return 9;
    return 15;
  }

  private static int getDeviceId(String paramString)
  {
    int i = IMCommonUtil.getDeviceIdMask();
    int j = i;
    Iterator localIterator;
    if ((paramString != null) && (paramString.length() > 0))
    {
      j = 0;
      localIterator = Arrays.asList(paramString.split(",")).iterator();
    }
    while (true)
    {
      int k;
      if (localIterator.hasNext())
      {
        k = Utils.getIntValue((String)localIterator.next(), Integer.valueOf(i)).intValue();
        if (k == i)
          j = i;
      }
      else
      {
        return j;
      }
      j |= k;
    }
  }

  private static IMAdRequest.EducationType getEducationType(String paramString)
  {
    if (paramString == null);
    do
    {
      return null;
      if (paramString.equalsIgnoreCase("bachelor"))
        return IMAdRequest.EducationType.Edu_BachelorsDegree;
      if (paramString.equalsIgnoreCase("doctor"))
        return IMAdRequest.EducationType.Edu_DoctoralDegree;
      if (paramString.equalsIgnoreCase("highschool"))
        return IMAdRequest.EducationType.Edu_HighSchool;
      if (paramString.equalsIgnoreCase("inCollege"))
        return IMAdRequest.EducationType.Edu_InCollege;
      if (paramString.equalsIgnoreCase("master"))
        return IMAdRequest.EducationType.Edu_MastersDegree;
      if (paramString.equalsIgnoreCase("other"))
        return IMAdRequest.EducationType.Edu_Other;
      if (paramString.equalsIgnoreCase("someCollege"))
        return IMAdRequest.EducationType.Edu_SomeCollege;
    }
    while (!paramString.equalsIgnoreCase("none"));
    return IMAdRequest.EducationType.Edu_None;
  }

  private static IMAdRequest.EducationType getEducationTypeFromClient(String paramString)
  {
    if (paramString == null);
    do
    {
      return null;
      if (paramString.equalsIgnoreCase("bachelor"))
        return IMAdRequest.EducationType.Edu_BachelorsDegree;
      if (paramString.equalsIgnoreCase("doctor"))
        return IMAdRequest.EducationType.Edu_DoctoralDegree;
      if (paramString.equalsIgnoreCase("highschool"))
        return IMAdRequest.EducationType.Edu_HighSchool;
      if (paramString.equalsIgnoreCase("inCollege"))
        return IMAdRequest.EducationType.Edu_InCollege;
      if (paramString.equalsIgnoreCase("master"))
        return IMAdRequest.EducationType.Edu_MastersDegree;
      if ((paramString.equalsIgnoreCase("other")) || (paramString.equalsIgnoreCase("professional")))
        return IMAdRequest.EducationType.Edu_Other;
      if (paramString.equalsIgnoreCase("someCollege"))
        return IMAdRequest.EducationType.Edu_SomeCollege;
    }
    while (!paramString.equalsIgnoreCase("none"));
    return IMAdRequest.EducationType.Edu_None;
  }

  private static IMAdRequest.EthnicityType getEthnicityType(String paramString)
  {
    if (paramString == null);
    do
    {
      return null;
      if (paramString.equalsIgnoreCase("asian"))
        return IMAdRequest.EthnicityType.Eth_Asian;
      if (paramString.equalsIgnoreCase("black"))
        return IMAdRequest.EthnicityType.Eth_Black;
      if (paramString.equalsIgnoreCase("hispanic"))
        return IMAdRequest.EthnicityType.Eth_Hispanic;
      if (paramString.equalsIgnoreCase("mixed"))
        return IMAdRequest.EthnicityType.Eth_Mixed;
      if (paramString.equalsIgnoreCase("nativeAmerican"))
        return IMAdRequest.EthnicityType.Eth_NativeAmerican;
      if (paramString.equalsIgnoreCase("other"))
        return IMAdRequest.EthnicityType.Eth_Other;
      if (paramString.equalsIgnoreCase("white"))
        return IMAdRequest.EthnicityType.Eth_White;
    }
    while (!paramString.equalsIgnoreCase("none"));
    return IMAdRequest.EthnicityType.Eth_None;
  }

  private static IMAdRequest.EthnicityType getEthnicityTypeFromClient(String paramString)
  {
    if (paramString == null);
    do
    {
      return null;
      if (paramString.equalsIgnoreCase("asian"))
        return IMAdRequest.EthnicityType.Eth_Asian;
      if (paramString.equalsIgnoreCase("black"))
        return IMAdRequest.EthnicityType.Eth_Black;
      if (paramString.equalsIgnoreCase("hispanic"))
        return IMAdRequest.EthnicityType.Eth_Hispanic;
      if (paramString.equalsIgnoreCase("mixed"))
        return IMAdRequest.EthnicityType.Eth_Mixed;
      if (paramString.equalsIgnoreCase("nativeAmerican"))
        return IMAdRequest.EthnicityType.Eth_NativeAmerican;
      if ((paramString.equalsIgnoreCase("other")) || (paramString.equalsIgnoreCase("indian")) || (paramString.equalsIgnoreCase("middleEastern")) || (paramString.equalsIgnoreCase("pacificIslander")))
        return IMAdRequest.EthnicityType.Eth_Other;
      if (paramString.equalsIgnoreCase("white"))
        return IMAdRequest.EthnicityType.Eth_White;
    }
    while (!paramString.equalsIgnoreCase("none"));
    return IMAdRequest.EthnicityType.Eth_None;
  }

  private static IMAdRequest.GenderType getGenderType(String paramString)
  {
    if (paramString == null)
      return IMAdRequest.GenderType.NONE;
    if (paramString.equalsIgnoreCase("female"))
      return IMAdRequest.GenderType.FEMALE;
    if (paramString.equalsIgnoreCase("male"))
      return IMAdRequest.GenderType.MALE;
    return IMAdRequest.GenderType.NONE;
  }

  private void setAdSize(Map<String, ?> paramMap)
  {
    this.mAdUnit = getAdUnitCode((String)paramMap.get("adSizeCodeValue"));
    Object localObject = paramMap.get("adUnit");
    if (localObject != null)
      this.mAdUnit = getAdUnitCode((String)localObject);
  }

  private void setInterstitial(Map<String, ?> paramMap)
  {
    Object localObject1 = paramMap.get("isCodeValueInterstitial");
    if (localObject1 != null)
      this.mIsInterstitial = ((Boolean)localObject1).booleanValue();
    Object localObject2 = paramMap.get("isInterstitial");
    if (localObject2 != null)
      this.mIsInterstitial = Boolean.parseBoolean((String)localObject2);
  }

  protected void applyClientTargetingParamsToNetwork(Map<String, String> paramMap)
  {
    String str1 = (String)paramMap.get("dateOfBirth");
    Date localDate;
    if (str1 != null)
    {
      localDate = Utils.getDateFromString(str1, "dd-MM-yyyy");
      this.mDateOfBirth = localDate;
      if (localDate == null);
    }
    try
    {
      this.mAge = getAge(localDate).intValue();
      label49: this.mAreaCode = ((String)paramMap.get("areaCode"));
      this.mEducationType = getEducationTypeFromClient((String)paramMap.get("educationType"));
      this.mEthnicityType = getEthnicityTypeFromClient((String)paramMap.get("ethnicityType"));
      this.mGenderType = getGenderType((String)paramMap.get("gender"));
      this.mIncome = Utils.getIntValue((String)paramMap.get("income"), Integer.valueOf(-1)).intValue();
      String str2 = (String)paramMap.get("keyWords");
      if (str2 != null)
        this.mKeywords = str2.replace(' ', ',');
      this.mPostalCode = ((String)paramMap.get("postalCode"));
      return;
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
      break label49;
    }
  }

  public void configure(IMAdRequest paramIMAdRequest)
  {
    if (this.mAge != -1)
      paramIMAdRequest.setAge(this.mAge);
    if (this.mAreaCode != null)
      paramIMAdRequest.setAreaCode(this.mAreaCode);
    if ((this.mCity != null) && (this.mState != null) && (this.mCountry != null))
      paramIMAdRequest.setLocationWithCityStateCountry(this.mCity, this.mState, this.mCountry);
    if (this.mDateOfBirth != null)
    {
      Calendar localCalendar = Calendar.getInstance();
      localCalendar.setTime(this.mDateOfBirth);
      paramIMAdRequest.setDateOfBirth(localCalendar);
    }
    if (this.mEducationType != null)
      paramIMAdRequest.setEducation(this.mEducationType);
    if (this.mEthnicityType != null)
      paramIMAdRequest.setEthnicity(this.mEthnicityType);
    if ((this.mIdType != null) && (this.mIdTypeValue != null))
      paramIMAdRequest.addIDType(this.mIdType, this.mIdTypeValue);
    if (this.mGenderType != null)
      paramIMAdRequest.setGender(this.mGenderType);
    if (this.mIncome != -1)
      paramIMAdRequest.setIncome(this.mIncome);
    if (this.mInterests != null)
      paramIMAdRequest.setInterests(this.mInterests);
    if (this.mKeywords != null)
      paramIMAdRequest.setKeywords(this.mKeywords);
    if (this.mPostalCode != null)
      paramIMAdRequest.setPostalCode(this.mPostalCode);
    if (this.mSearchString != null)
      paramIMAdRequest.setSearchString(this.mSearchString);
    IMCommonUtil.setDeviceIDMask(this.mDeviceIdMask);
    paramIMAdRequest.setLocationInquiryAllowed(this.mIsLocationAllowed);
    paramIMAdRequest.setTestMode(this.mIsTestMode);
    enableProperLogLevel(this.mLogLevel);
  }

  int getAdUnit()
  {
    return this.mAdUnit;
  }

  String getAppId()
  {
    return this.mAppId;
  }

  boolean isInterstitial()
  {
    return this.mIsInterstitial;
  }

  public void readParameters(Map<String, ?> paramMap)
    throws IllegalArgumentException
  {
    applyClientTargetingIfAllowed(paramMap);
    this.mAppId = ((String)paramMap.get("appId"));
    Utils.checkNotNull(this.mAppId, "appId cannot be null");
    setInterstitial(paramMap);
    if (!this.mIsInterstitial)
      setAdSize(paramMap);
    this.mIsTestMode = Boolean.parseBoolean((String)paramMap.get("testMode"));
    this.mLogLevel = ((String)paramMap.get("logLevel"));
    this.mAge = Utils.getIntValue((String)paramMap.get("age"), Integer.valueOf(-1)).intValue();
    this.mAreaCode = ((String)paramMap.get("areaCode"));
    this.mDateOfBirth = Utils.getDateFromString((String)paramMap.get("dateOfBirth"), "dd/MM/yyyy");
    this.mDeviceIdMask = getDeviceId((String)paramMap.get("deviceIdMask"));
    this.mEducationType = getEducationType((String)paramMap.get("educationType"));
    this.mEthnicityType = getEthnicityType((String)paramMap.get("ethnicityType"));
    this.mGenderType = getGenderType((String)paramMap.get("genderType"));
    this.mIncome = Utils.getIntValue((String)paramMap.get("income"), Integer.valueOf(-1)).intValue();
    this.mInterests = ((String)paramMap.get("interests"));
    this.mKeywords = ((String)paramMap.get("keywords"));
    this.mPostalCode = ((String)paramMap.get("postalCode"));
    this.mSearchString = ((String)paramMap.get("searchString"));
    this.mIsLocationAllowed = Boolean.parseBoolean((String)paramMap.get("locationAllowed"));
    extractIdType(paramMap);
    extractCityStateCountryLocation(paramMap);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.inmobi.InmobiConfigurator
 * JD-Core Version:    0.6.2
 */